package com.houmeiyuan.huiguniang.ctrl;

import com.houmeiyuan.huiguniang.common.Result;
import com.houmeiyuan.huiguniang.ctrl.BaseCtrl;
import com.houmeiyuan.huiguniang.service.WXLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;


@RestController
@RefreshScope
@RequestMapping("/wx")
public class HgnWXCtrl extends BaseCtrl {
    @Autowired
    private WXLoginService service;

    @RequestMapping("/login")
    public Result wechatLogin(@RequestParam("code") String code, HttpServletResponse response) {
        Map<String, Object> result = new HashMap<>();
        result = service.onLogin(code, response);
        return send(result);
    }

}
